<html>
<head>
    <title>appDemo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body >
<h1>app api 测试</h1>
<button onclick="getText()">获取内容</button>
<button onclick="setText()">写入内容</button>
<button onclick="clearText()">清除内容</button>
<script>
    var gui = require('nw.gui');
    // We can not create a clipboard, we have to receive the system clipboard
    var clipboard = gui.Clipboard.get();
    function apendText(text) {
        var element = document.createElement('div');
        element.appendChild(document.createTextNode(text));
        document.body.appendChild(element);
    }
    function clearText()
    {
        // And clear it!
        clipboard.clear();
        apendText('剪贴板内容已清除');
    }
    function setText()
    {
        // Or write something
        clipboard.set('这是node-webkit向剪贴板写的内容', 'text');
    }
    function getText()
    {
        // Read from clipboard
        var text = clipboard.get('text');
        apendText(text);
    }
</script>
</body>
</html>